//
//  ChatFunctionPanel.m
//  TIMChat
//
//  Created by AlexiChen on 16/3/21.
//  Copyright © 2016年 AlexiChen. All rights reserved.
//

#import "ChatFunctionPanel.h"


@implementation ChatFunctionPanel

- (instancetype)init
{
    if (self = [super init])
    {
        _contentHeight = 210;
        
    }
    return self;
}
- (void)addOwnViews
{
    _moneyImage = [[ImageTitleButton alloc] initWithStyle:EImageTopTitleBottom];
    _moneyImage.imageSize = CGSizeMake(60, 60);
    _moneyImage.margin = UIEdgeInsetsMake(10, 0, 0, 10);
    _moneyImage.titleLabel.textAlignment = NSTextAlignmentCenter;
    _moneyImage.titleLabel.font = kAppMiddleTextFont;
    [_moneyImage setTitleColor:kGrayColor forState:UIControlStateNormal];
    [_moneyImage setTitle:@"红包照片" forState:UIControlStateNormal];
    [_moneyImage setImage:[UIImage imageNamed:@"redImag"] forState:UIControlStateNormal];
    [_moneyImage addTarget:self action:@selector(onClickMoneyImage:) forControlEvents:UIControlEventTouchUpInside];
    [self addSubview:_moneyImage];
    
    _moneyVideo = [[ImageTitleButton alloc] initWithStyle:EImageTopTitleBottom];
    _moneyVideo.imageSize = CGSizeMake(60, 60);
    _moneyVideo.margin = UIEdgeInsetsMake(10, 0, 0, 10);
    _moneyVideo.titleLabel.textAlignment = NSTextAlignmentCenter;
    _moneyVideo.titleLabel.font = kAppMiddleTextFont;
    [_moneyVideo setTitleColor:kGrayColor forState:UIControlStateNormal];
    [_moneyVideo setTitle:@"红包视频" forState:UIControlStateNormal];
    
    [_moneyVideo setImage:[UIImage imageNamed:@"redVideo"] forState:UIControlStateNormal];
    [_moneyVideo addTarget:self action:@selector(onClickMoneyVideo:) forControlEvents:UIControlEventTouchUpInside];
    [self addSubview:_moneyVideo];
    
    _freeImage = [[ImageTitleButton alloc] initWithStyle:EImageTopTitleBottom];
    _freeImage.imageSize = CGSizeMake(60, 60);
    _freeImage.margin = UIEdgeInsetsMake(10, 0, 0, 10);
    _freeImage.titleLabel.textAlignment = NSTextAlignmentCenter;
    _freeImage.titleLabel.font = kAppMiddleTextFont;
    [_freeImage setTitleColor:kGrayColor forState:UIControlStateNormal];
    [_freeImage setTitle:@"照片" forState:UIControlStateNormal];
    
    [_freeImage setImage:[UIImage imageNamed:@"freePhoto"] forState:UIControlStateNormal];
    [_freeImage addTarget:self action:@selector(onClickFreeImage:) forControlEvents:UIControlEventTouchUpInside];
    [self addSubview:_freeImage];
    
    _playvideo = [[ImageTitleButton alloc] initWithStyle:EImageTopTitleBottom];
    _playvideo.imageSize = CGSizeMake(60, 60);
    _playvideo.margin = UIEdgeInsetsMake(10, 0, 0, 10);
    _playvideo.titleLabel.textAlignment = NSTextAlignmentCenter;
    [_playvideo setTitleColor:kGrayColor forState:UIControlStateNormal];
    _playvideo.titleLabel.font = kAppMiddleTextFont;
    [_playvideo setTitle:@"视频聊天" forState:UIControlStateNormal];
    [_playvideo setImage:[UIImage imageNamed:@"videoChat"] forState:UIControlStateNormal];
    [_playvideo addTarget:self action:@selector(onClickChatVideo:) forControlEvents:UIControlEventTouchUpInside];
    [self addSubview:_playvideo];
    
//    _voice = [[ImageTitleButton alloc] initWithStyle:EImageTopTitleBottom];
//    _voice.imageSize = CGSizeMake(60, 60);
//    _voice.margin = UIEdgeInsetsMake(10, 0, 0, 10);
//    _voice.titleLabel.textAlignment = NSTextAlignmentCenter;
//    [_voice setTitleColor:kGrayColor forState:UIControlStateNormal];
//    _voice.titleLabel.font = kAppMiddleTextFont;
//    [_voice setTitle:@"语音聊天" forState:UIControlStateNormal];
//    [_voice setImage:[UIImage imageNamed:@"voiceChat"] forState:UIControlStateNormal];
//    [_voice addTarget:self action:@selector(onClickChatVoice:) forControlEvents:UIControlEventTouchUpInside];
//    [self addSubview:_voice];
    
    _flower = [[ImageTitleButton alloc] initWithStyle:EImageTopTitleBottom];
    _flower.imageSize = CGSizeMake(60, 60);
    _flower.margin = UIEdgeInsetsMake(10, 0, 0, 10);
    _flower.titleLabel.textAlignment = NSTextAlignmentCenter;
    [_flower setTitleColor:kGrayColor forState:UIControlStateNormal];
    _flower.titleLabel.font = kAppMiddleTextFont;
    [_flower setTitle:@"礼物" forState:UIControlStateNormal];
    [_flower setImage:[UIImage imageNamed:@"sendeGift"] forState:UIControlStateNormal];
    [_flower addTarget:self action:@selector(onClickFlower:) forControlEvents:UIControlEventTouchUpInside];
    [self addSubview:_flower];
    
}

- (void)onClickMoneyImage:(UIButton *)btn
{
    if ([_chatDelegate respondsToSelector:@selector(onChatInputSendMoneyImage:)])
    {
        [_chatDelegate onChatInputSendMoneyImage:self];
    }
}

- (void)onClickMoneyVideo:(UIButton *)btn
{
    if ([_chatDelegate respondsToSelector:@selector(onChatInputSendMoneyVideo:)])
    {
        [_chatDelegate onChatInputSendMoneyVideo:self];
    }
}

- (void)onClickFreeImage:(UIButton *)btn
{
    if ([_chatDelegate respondsToSelector:@selector(onChatInputSendFreeImage:)])
    {
        [_chatDelegate onChatInputSendFreeImage:self];
    }
}
- (void)onClickChatVideo:(UIButton *)btn
{
    if ([_chatDelegate respondsToSelector:@selector(onChatInputChatVideo:)])
    {
        [_chatDelegate onChatInputChatVideo:self];
    }
}

- (void)onClickChatVoice:(UIButton *)btn
{
    if ([_chatDelegate respondsToSelector:@selector(onChatInputChatVoice:)])
    {
        [_chatDelegate onChatInputChatVoice:self];
    }
}

- (void)onClickFlower:(UIButton *)btn
{
    if ([_chatDelegate respondsToSelector:@selector(onChatInputFlower:)])
    {
        [_chatDelegate onChatInputFlower:self];
    }
}

- (void)relayoutFrameOfSubViews {

        if ([[UserDefaults objectForKey:@"isnowchat"] boolValue] == YES) {
            [self alignSubviews:@[ _freeImage] horizontallyWithPadding:0 margin:0 inRect:CGRectMake(0, 0, XQScreenW / 4, 105)];

        }else {
            [self alignSubviews:@[_moneyImage, _moneyVideo, _freeImage, _playvideo] horizontallyWithPadding:0 margin:0 inRect:CGRectMake(0, 0, XQScreenW, 105)];
            [self alignSubviews:@[ _flower] horizontallyWithPadding:0 margin:0 inRect:CGRectMake(0, 105, XQScreenW / 4, 105)];

        }
    
}


@end
